<template>
  <div class="cell">
    <div class="cell__row" :style="{ paddingLeft: `${item.layer * 20 + 10}px`}">
      <span
        class="checkbox__btn"
        :class="{
          checked: item.checked === 'checked',
          'half-checked': item.checked === 'half-checked'
        }"
        @click="$emit('action', { type: 'select', item: item })"
      >
        <span class="checkbox__inner"></span>
      </span>
      <span>{{ item.button_name }}</span>
    </div>
    <div class="cell__row">
      {{ item.button_id }}
    </div>
    <div class="cell__row">
      <el-button size="mini" type="primary" @click="$emit('action', { type: 'edit', item: item })">编辑</el-button>
      <el-button size="mini" type="primary" @click="$emit('action', { type: 'add-sub', item: item })">添加子节点</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: '',
  props: {
    item: {
      type: Object,
      default: () => {}
    }
  },
  methods: {

  }
}
</script>

<style lang="scss" scoped>
.cell {
  display: grid;
  grid-template-columns: var(--grid-template-columns);
  box-sizing: border-box;
  height: 100%;
  overflow: hidden;
}
.cell__row {
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-right: 0;
  border-top: 0;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  box-sizing: border-box;
  span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .arrow__btn {
    cursor: pointer;
    transform: rotate(-90deg);
    &.expand {
      transform: rotate(0deg);
    }
  }
}
.checkbox__btn {
  width: 16px;
  height: 16px;
  cursor: pointer;
  .checkbox__inner {
    display: inline-block;
    position: relative;
    border: 1px solid #dcdfe6;
    border-radius: 2px;
    box-sizing: border-box;
    width: 16px;
    height: 16px;
    background-color: #fff;
    z-index: 1;
    transition: border-color .25s cubic-bezier(.71,-.46,.29,1.46),background-color .25s cubic-bezier(.71,-.46,.29,1.46);
    // transition: transform .15s ease-in .05s;
    &::after {
      box-sizing: content-box;
      content: "";
      border: 1px solid #fff;
      border-left: 0;
      border-top: 0;
      height: 7px;
      left: 5px;
      top: 3px;
      position: absolute;
      transform: rotate(45deg) scaleY(0);
      width: 3px;

      transform-origin: center;
    }
  }
  &.checked {
    .checkbox__inner {
      background-color: #409eff;
      border-color: #409eff;
      &::after {
        transform: rotate(45deg) scaleY(1)
      }
    }
  }
  &.half-checked {
    .checkbox__inner {
      background-color: #409eff;
      border-color: #409eff;
      &::after {
        transform: rotate(90deg) scaleY(1);
        border-bottom: 0;
      }
    }
  }
}
</style>
